#include "stdafx.h" // include standard stuff, like tdd.h, tddAssert.h (if you can use ATL), windows.h, etc.
#include "ExampleClass.h" // header for the example class we want to test

namespace SomeNamespaceUsedForGroupingTests // this will show up in the gui test runner's treeview as a top-level item
{
namespace AnotherDeeperNamespace // this will show up in the gui test runner's treeview as a child of SomeNamespaceUsedForGroupingTests
{
TESTCLASS(ExampleClassTests) // a class to hold a bunch of tests.  It's real class - you can inherit from other classes, have data members, etc.
{
private:
	ExampleClass* m_pEC; // an example class that tests for primality

public:
	ExampleClassTests() : m_pEC(NULL) {} // constructors should either not exist or at least run very fast...

private:
	virtual void TestInitialize() // ... lazy initialization goes here.  This is called before each test method is run.
	{
		m_pEC = new ExampleClass;
	}
	virtual void TestCleanup() // this is called after each test method is run.
	{
		delete m_pEC;
	}
	// also available are ClassInitialize() and ClassCleanup() which are run once before and after all the test methods are run.

private: // or public, as you please
	TESTMETHOD(Is2Prime) // a test method
	{
		m_pEC->Set(2);
		TddAssert().IsTrue(m_pEC->IsPrime(), L"2 is prime");
	}
	TESTMETHOD(Is3Prime) // another
	{
		m_pEC->Set(3);
		TddAssert().IsTrue(m_pEC->IsPrime(), L"3 is prime");
	}
	TESTMETHOD(Is4Prime)
	{
		m_pEC->Set(4);
		TddAssert().IsFalse(m_pEC->IsPrime(), L"4 is not prime");
	}

	TESTMETHOD(SetNotCalledTest)
	{
		TddAssert().IsFalse(m_pEC->IsPrime(), L"-1 is not prime");
	}

	// a whole bunch of tests, showing refactorability
	TESTMETHOD(Test5ForPrimality)  { RefactoredTest( 5, true,  L"5 is prime"); }
	TESTMETHOD(Test6ForPrimality)  { RefactoredTest( 6, false, L"6 is not prime"); }
	TESTMETHOD(Test7ForPrimality)  { RefactoredTest( 7, true,  L"7 is prime"); }
	TESTMETHOD(Test8ForPrimality)  { RefactoredTest( 8, false, L"8 is not prime"); }
	TESTMETHOD(Test9ForPrimality)  { RefactoredTest( 9, false, L"9 is not prime"); }
	TESTMETHOD(Test10ForPrimality) { RefactoredTest(10, false, L"10 is not prime"); }
	TESTMETHOD(Test11ForPrimality) { RefactoredTest(11, true,  L"11 is prime"); }
	TESTMETHOD(Test12ForPrimality) { RefactoredTest(12, false, L"12 is not prime"); }
	TESTMETHOD(Test13ForPrimality) { RefactoredTest(13, true,  L"13 is prime"); }
	TESTMETHOD(Test14ForPrimality) { RefactoredTest(14, false, L"14 is not prime"); }
	TESTMETHOD(Test15ForPrimality) { RefactoredTest(15, false, L"15 is not prime"); }
	TESTMETHOD(Test16ForPrimality) { RefactoredTest(16, false, L"16 is not prime"); }
	TESTMETHOD(Test17ForPrimality) { RefactoredTest(17, true,  L"17 is prime"); }
	TESTMETHOD(Test18ForPrimality) { RefactoredTest(18, false, L"18 is not prime"); }

	TESTMETHOD(KnownBigPrime) { RefactoredTest(15487457, true, L"15487457 is prime"); }

	TESTMETHOD(TestNegativeNumber) { RefactoredTest(-1, false, L"-1 is not prime"); }
	TESTMETHOD(TestZero)           { RefactoredTest (0, false, L"0 is not prime"); }
	TESTMETHOD(TestOne)            { RefactoredTest (1, false, L"1 is not prime"); }


private:
	void RefactoredTest(int i, bool b, const WCHAR* hint)
	{
		m_pEC->Set(i);
		TddAssert().AreEqual(b, m_pEC->IsPrime(), hint);
	}
};
}
}